<%@ page session="false"%>
<%@ page contentType="text/html;charset=UTF8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>用户管理</title>
<jsp:include page="../header.jsp" flush="true" />

<style type="text/css">
<!--
.STYLE1 {
	font-size: small
}
-->
</style>
<script language="JAVASCRIPT">
	function validateForm(myform) {
		if (myform.email.value == "") {
			alert("邮箱为必填项， 请正确填写.");
			return false;
		}
		var re = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
		if (!re.test(myform.email.value)) {
			alert("邮箱格式不正确， 请正确填写.");
			return false;
		}
		if (myform.realName.value == "") {
			alert("姓名为必填项， 请正确填写.");
			return false;
		}
		if (myform.role.value == "-1") {
			alert("权限为必选项， 请选择.");
			return false;
		}
		if (myform.groupID.value == "-1") {
			alert("团队为必选项， 请正确填写.");
			return false;
		}
		return true;
	}
</script>

<table cellpadding="0" cellspacing="0" class="style5">
	<tr>
		<td colspan="4" bgcolor="#FFFBD6"><span
			id="ctl00_ContentPlaceHolder1_Label4"
			style="color: #990000; background-color: #FFCC66; font-size: small">用户目录</span>
		</td>
	</tr>
	<tr>
		<td colspan="4">
		<div>
		<table cellspacing="0" cellpadding="4" border="0"
			id="ctl00_ContentPlaceHolder1_GridView1"
			style="color: #333333; width: 100%; border-collapse: collapse; font-size: small; font-family: Arial">
			<tr
				style="color: White; background-color: #507CD1; font-weight: bold;">
				<th scope="col"></th>
				<th scope="col" style="color: White;">姓名</th>
				<th scope="col" style="color: White;">团队</th>
				<th scope="col" style="color: White;">职位</th>
				<th scope="col" style="color: White;">办公电话</th>
				<th scope="col" style="color: White;">移动电话</th>
				<th scope="col" style="color: White;">传真号码</th>
				<th scope="col" style="color: White;">电子邮箱</th>
				<th scope="col" style="color: White;">上司</th>
				<th scope="col" style="color: White;">注册日期</th>
				<th scope="col" style="color: White;">状态</th>
			</tr>
			<c:forEach var="user" items="${users}" varStatus="rowCounter">
				<c:choose>
					<c:when test="${rowCounter.count % 2 == 0}">
						<c:set var="bgColor" scope="page" value="#EFF3FB;" />
					</c:when>
					<c:otherwise>
						<c:set var="bgColor" scope="page" value="#FFFFFF;" />
					</c:otherwise>
				</c:choose>
				<tr style="background-color: ${bgColor}">
					<td style="width: 20px;"></td>
					<td><c:choose>
						<c:when test='${user.userVO.userID==1}'>
${user.userVO.realName}
</c:when>
						<c:otherwise>
							<a href="manageUser.do?action=edit&id=${user.userID}">${user.userVO.realName}</a>
						</c:otherwise>
					</c:choose></td>
					<td>${user.userVO.groupName}</td>
					<td>${user.userVO.title}</td>
					<td>${user.userVO.officeTel}</td>
					<td>${user.userVO.mobileTel}</td>
					<td>${user.userVO.fax}</td>
					<td>${user.userVO.email}</td>
					<td>${user.userVO.superior}</td>
					<td><fmt:formatDate value="${user.userVO.registerDate}"
						pattern="yyyy-MM-dd" /></td>
					<td><c:choose>
						<c:when test='${user.userVO.userID==1}'>
内置管理员帐号
							</c:when>
						<c:when test='${user.userVO.status=="Active"}'>
已激活，<a href="manageUser.do?action=freeze&id=${user.userID}">冻结用户</a>
						</c:when>
						<c:otherwise>
已冻结，<a href="manageUser.do?action=active&id=${user.userID}">激活用户</a>
						</c:otherwise>
					</c:choose></td>
				</tr>
			</c:forEach>
		</table>
		</div>
		</td>
	</tr>
	<tr>
		<td colspan="4" style="text-align: center">&nbsp;</td>
	</tr>
	<form:form id="userForm" name="userForm" commandName="userForm"
		onsubmit="return validateForm(this);">
		<tr>
			<td colspan="4" bgcolor="#FFFBD6"><span
				id="ctl00_ContentPlaceHolder1_Label5"
				style="color: #990000; background-color: #FFCC66; font-size: small">信息维护</span>
			<form:errors path="*" /> ${errors.errorCount}</td>
		</tr>
		<tr>
			<td style="text-align: right; font-size: small">邮箱(*)：</td>
			<td><form:input path="email"
				cssStyle="height: 16px; width: 200px;" /></td>
			<td style="text-align: right; font-size: small">职位：</td>
			<td><form:input path="title"
				cssStyle="height: 16px; width: 200px;" /></td>
		</tr>
		<tr>

			<td style="text-align: right; font-size: small">姓名(*)：</td>
			<td><form:input path="realName"
				cssStyle="height: 16px; width: 200px;" /></td>

			<td style="text-align: right; font-size: small">办公电话：</td>
			<td><form:input path="officeTel"
				cssStyle="height: 16px; width: 200px;" /></td>

		</tr>
		<tr>
			<td class="style4 STYLE1" style="text-align: right">团队(*)：</td>
			<td><form:select path="groupID"
				cssStyle="height: 23px; width: 200px;">
				<form:option value="-1" label="--请选择--" />
				<form:options items="${userForm.groupList}" itemValue="groupID"
					itemLabel="groupName" />
			</form:select></td>
			<td style="text-align: right; font-size: small">移动电话：</td>
			<td><form:input path="mobileTel"
				cssStyle="height: 16px; width: 200px;" /></td>
		</tr>
		<tr>
			<td style="text-align: right; font-size: small">权限(*)：</td>
			<td><form:select path="role"
				cssStyle="height: 23px; width: 120px;">
				<form:option value="-1" label="----请选择----" />
				<form:options items="${userForm.roleList}" itemValue="name"
					itemLabel="translatedName" />
			</form:select></td>
			<td style="text-align: right; font-size: small">传真号码：</td>
			<td><form:input path="fax"
				cssStyle="height: 16px; width: 200px;" /></td>
		</tr>
		<tr>
			<td style="text-align: right; font-size: small">登录密码:</td>
			<td><form:input path="password"
				cssStyle="height: 16px; width: 200px;" /></td>

			<td />
			<td />
		</tr>
		<c:if test='${userForm.email != null}'>
			<form:hidden path="userID" />
		</c:if>
		<tr>
			<td colspan="4" style="text-align: center">&nbsp; <input
				type="submit" name="submit"
				value="<c:choose><c:when test='${userForm.userID > 0}'>更新用户</c:when><c:otherwise>创建用户</c:otherwise></c:choose>"
				id="ctl00_ContentPlaceHolder1_Button6" /> &nbsp; <input
				type="button" name="clear" value="清空表格" id="clear"
				onClick="location.href='manageUser.do'" /></td>
		</tr>
	</form:form>
</table>

</td>
</tr>
</table>
<jsp:include page="../footer.jsp"></jsp:include>
</body>
</html>
